@extends('admin')
@section('content')
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="/">首页</a>
                <i class="icon-double-angle-right"></i>
                <span>商品</span>
            </li>

        </ul><!-- .breadcrumb -->

        <!-- #nav-search -->
    </div>

    <div class="page-content">

        <div class="alert alert-block hidden">
            <button type="button" class="close" data-dismiss="alert">
                <i class="icon-remove"></i>
            </button>

            <i class="icon-tip"></i>
            <strong class=""></strong>
        </div>

        <div class="row">
            <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <form class="form-horizontal" action="product-save.html" method="post" role="form" enctype="multipart/form-data">
                    <input type="hidden" name="id" value="{{ $goods->id }}">
                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 产品简称 </label>
                        <div class="col-sm-9">
                            <select name="brand_id" value="{{ $goods->product_id }}"  class="col-xs-10 col-sm-8">
                                @foreach($productList as $product)
                                    <option value="{{ $product->id }}" @if($goods->product_id === $product->id)selected="selected"@endif>{{ $product->short }}</option>
                                @endforeach
                            </select>
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 规格 </label>

                        <div class="col-sm-9">
                            <input type="text" name="spec" placeholder="规格" value="{{ $goods->spec }}" class="col-xs-10 col-sm-8">
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 单位 </label>

                        <div class="col-sm-9">
                            <input type="text" name="unit" placeholder="单位" value="{{ $goods->unit }}" class="col-xs-10 col-sm-8">
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 值 </label>

                        <div class="col-sm-9">
                            <input type="text" name="value" placeholder="值" value="{{ $goods->value }}" class="col-xs-10 col-sm-8">
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 颜色 </label>

                        <div class="col-sm-9">
                            <select name="brand_id" value="{{ $goods->color_id }}"  class="col-xs-10 col-sm-8">
                                @foreach($colorList as $color)
                                    <option value="{{ $color->id }}" @if($goods->color_id === $color->id)selected="selected"@endif>{{ $color->name }}</option>
                                @endforeach
                            </select>
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 价格 </label>

                        <div class="col-sm-9">
                            <input type="text" name="price" placeholder="价格" value="{{ $goods->price }}" class="col-xs-10 col-sm-8">
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right"> 库存数量 </label>

                        <div class="col-sm-9">
                            <input type="text" name="storage" placeholder="库存数量" value="{{ $goods->storage }}" class="col-xs-10 col-sm-8">
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 主图 </label>
                        <div class="col-sm-9">
                            <div id="pickcontainer" class="widget-main col-xs-10 col-sm-8">
                                <a class="a-upload-images" href="#">
                                    <img src="{{ $goods->pic ? : '/assets/images/empty.png' }}" title="点击上传图片" style="width:150px;height: 200px;">
                                </a>
                                <input type="hidden" name="pic" value="{{ $goods->pic }}">

                            </div>
                            <span class="help-inline col-xs-12 col-sm-4">
                                <span class="middle"></span>
                            </span>
                        </div>
                    </div>

                    <div class="space-4"></div>

                    <div class="clearfix form-actions">
                        <div class="col-md-offset-3 col-md-9">
                            <button class="btn btn-info" type="submit">
                                <i class="icon-ok bigger-110"></i>
                                保存
                            </button>

                            &nbsp; &nbsp; &nbsp;
                            <button class="btn" type="reset">
                                <i class="icon-undo bigger-110"></i>
                                取消
                            </button>
                        </div>
                    </div>

                    <div class="hr hr-24"></div>

                </form>

            </div><!-- /.col -->
            <div class="click-div hidden">
                <input type="file" class="upload-images" name="upfile">
            </div>
        </div><!-- /.row -->
    </div>
@endsection
@section('custom-script')
    <script type="text/javascript" src="assets/js/ajaxupload.js"></script>
    <script type="text/javascript">
        $(function(){
            var uploader = new $.AjaxUploader('.upload-images',{
                success: function(json){
                    $('input[name="poster"]').val(json.file);
                    $('.a-upload-images img').attr('src', json.file);
                    $('.alert-block').removeClass('hidden').addClass('alert-success');
                    $('.alert-block i.icon-tip').removeClass('icon-remove').addClass('icon-ok');
                    $('.alert-block strong').text(json.message);
                },
                error: function(data, status, e){
                    $('.alert-block').removeClass('hidden').addClass('alert-danger');
                    $('.alert-block i.icon-tip').removeClass('icon-ok').addClass('icon-remove');
                    $('.alert-block strong').text(e);
                }
            });
            $('.a-upload-images').click(function(){
                $('.upload-images').click();
            });
            $('.upload-images').change(function(e){
                uploader.init('upload.html',null,'json');
                e.preventDefault();
            });
        });
    </script>
@endsection